<?php
if(!defined("IN_PHPSCUP"))exit("hacking");
class scupView {
	var $template_dir = '';
	var $cache_dir = '';
	var $compile_dir = '';

	var $widget_dir = '';

	var $widget_base_load = null;

	var $cache_lifetime = 3600; // 缓存更新时间, 默认 3600 秒
	var $direct_output = false; // 是否直接输出
	var $caching = true; // 是否缓存
	var $template = array ();
	var $force_compile = false; // 是否需要强制编译
	var $gzip = false;

	var $_var = array ();

	var $_current_file = '';

	var $_nowtime = null;

	function __construct() {
		$this->scupView();
	}

	function scupView() {
		$this->_nowtime = time();
	}

	/**
	 * 变量赋值
	 */
	function assign($tpl_var, $value = '') {
		if ($tpl_var != '') {
			$this->_var[$tpl_var] = $value;
		}
	}

	/**
	 *变量引用赋值
	 */
	function _assign($tpl_var, & $value) {
		if ($tpl_var != '') {
			$this->_var[$tpl_var] = & $value;
		}
	}

	//从新得到get数据，用于静态网页用2表示，和伪静态网页用1表示
	function _re_get_url() {
		if (SYSTEM_URL_REWRITE == 1) {
			$script_name = basename($_SERVER['SCRIPT_NAME']);
			$request_str = strstr($_SERVER['REQUEST_URI'], '?');
			$request_str = substr($request_str, 1);
			$request_str = preg_replace("/\.(html|htm|php)$/is","",$request_str);

			$request_arr = explode('-', $request_str);

			for ($i = 1; $i < count($request_arr);) {
				if (empty ($request_arr[$i])) {
					$i++;
					continue;
				}
                if(!isset($request_arr[$i +1]))
				{
				$request_arr[$i +1]='';
				}				 
				$_GET[trim($request_arr[$i])] = trim($request_arr[$i +1]);
				$i = $i +2;
			}
		} else if (SYSTEM_URL_REWRITE == 2) {

		}
	}

	//产生url链接，用于静态网页，和伪静态网页
	function _write_url($url_str) {
		if (preg_match("/^http:\/\//i", $url_str)) {
			return $url_str;
		}

		$url_array = explode('?', $url_str);
		$url_num = count($url_array);

		if ($url_num >= 3) {
			return SITE_URL;
		}

		if (!isset ($url_array[1])) {
			$url_array[1] = '';
		}

		if (SYSTEM_URL_REWRITE == 1) {

			if ($url_array[0] == 'index.php' || $url_array[0] == '') {
				$url_array[0] = '?';
			}

			if ($url_array[0] == '?') {
				$url = SITE_URL . '/?';
			} else {
				$url = SITE_URL . '/' . $url_array[0] . '?';
			}

			$icon = false;
			$arr = explode('&', $url_array[1]);
			foreach ($arr as $value) {
				if ($value) {
					$value = explode('=', $value);
					$url .= '-' . $value[0] . '-' . $value[1];
					$icon = true;

				}
			}

			$url .= '.html'; //url链接后缀如.html,.php或为空格""			 
		} else if (SYSTEM_URL_REWRITE == 2) 
		{
            if (defined("IS_PHPSCUP_ADMIN")) 
			{
             $url = SITE_URL . '/admin/index.php?' . $url_array[1];
            }
			else
			{
			$url = SITE_URL . '/index.php?' . $url_array[1];
            // $url = '?' . $url_array[1];
			}		
		
             
		} else 
		{
		
            if (defined("IS_PHPSCUP_ADMIN")) 
			{
             $url = SITE_URL . '/admin/index.php?' . $url_array[1];
            }
			else
			{
			$url = SITE_URL . '/index.php?' . $url_array[1];
            // $url = '?' . $url_array[1];
			}	
		}
		return $url;
	}

	
    //产生url链接，用于静态网页
    function _write_url_html($url_str)
    {     
	
		$url_array=explode('&',$url_str);
		$url_num = count($url_array);
		
		if($url_num >=3)
		{
		   return  SITE_URL;	
		}

		if(!isset($url_array[0]))
		{
		   return  SITE_URL; 
		}
		

		if(!isset($url_array[1]))
		{
		   return  SITE_URL; 
		}
		if(!isset($GLOBALS['SCup']->SCup_user_msg['data']['languages']))
		{
	    $GLOBALS['SCup']->SCup_user_msg['data']['languages']='';
		}
	
		$cookie_lang=get_cookie('languages');
		if(empty($cookie_lang))
		{		
		$cookie_lang = $GLOBALS['SCup']->SCup_user_msg['data']['languages'];		
		}	
		
	    if(empty($cookie_lang))
		{	
		   $lang_type = LANG;		  	  
		}
		else
		{
		 $lang_type = $cookie_lang;
		} 


	    $url = SITE_URL.'/'.$url_array[0].'/'. $url_array[1] .'.html';			 
  	
		return $url;
    }	

	
    function html($id,$siteurl,$app)
    {

		$content = @file_get_contents($siteurl);
		if(!isset($GLOBALS['SCup']->SCup_user_msg['data']['languages']))
		{
	    $GLOBALS['SCup']->SCup_user_msg['data']['languages']='';
		}	
		$cookie_lang=get_cookie('languages');
		if(empty($cookie_lang))
		{		
		$cookie_lang = $GLOBALS['SCup']->SCup_user_msg['data']['languages'];	
		}	
		
	    if(empty($cookie_lang))
		{	
		   $lang_type = LANG;		  	  
		}
		else
		{
		 $lang_type = $cookie_lang;
		} 

		$cachefilename = ROOT_PATH .'/'.$app.'/'. $id .'.html'; 

        get_dir(ROOT_PATH .'/'.$app.'/');
				 
		 file_put_contents($cachefilename,$content);   

    }	


    function delhtml($id,$app)
    { 
		del_file(ROOT_PATH .'/'.$app.'/'. $id  .'.html'); 

    }	




	/**
	* 显示页面函数
	*/
	function display($filename, $cache_id = '') {
		$icon_cache = false;
		if(!isset($GLOBALS['SCup']->SCup_user_msg['data']['languages']))
		{
	    $GLOBALS['SCup']->SCup_user_msg['data']['languages']='';
		}
		
		$cookie_lang=get_cookie('languages');
		if(empty($cookie_lang))
		{		
		$cookie_lang = $GLOBALS['SCup']->SCup_user_msg['data']['languages'];	
		}	
		if (empty ($cookie_lang)) {
			$lang_type = LANG;
		} else {
			$lang_type = $cookie_lang;
		}
		$cachefilename = $this->cache_dir . '/' . $lang_type . '/' . $filename . $cache_id . '.html';

		$cache_time = @ filemtime($cachefilename);

		if ($cache_id && $this->caching) {
			if (is_file($cachefilename) && ($this->_nowtime - $this->cache_lifetime <= $cache_time)) {
				echo @ file_get_contents($cachefilename);
				exit ();

			} else {
				$icon_cache = true;
			}
		}

		$out = $this->_template($filename);

		ob_start();
		eval ('?' . '>' . trim($out));
		$out = ob_get_contents();
		ob_end_clean();

		if ($icon_cache && ($this->_nowtime - $this->cache_lifetime > $cache_time)) {
			if (!file_exists($cachefilename)) {
				get_dir($this->cache_dir . '/' . $lang_type);
			}
			file_put_contents($cachefilename, $out);
		}
		echo $out;
	}

	/**
	 * 处理模板文件
	 */
	function _template($filename) {
		$vfilename = $this->template_dir . '/' . $filename;

		$cfilename = $this->compile_dir . '/' . $filename . '.phpscup';

		if (file_exists($cfilename) === false || @ filemtime($vfilename) > @ filemtime($cfilename)) {
			if (!is_file($vfilename)) {
				exit ("no exist view");
			}

			$out = "";
			if (!($out = file_get_contents($vfilename))) {
				return false;
			}
			$out = $this->template_str($out);

			if (!file_exists($cfilename)) {
				get_dir($this->compile_dir);

			}

			if (!file_put_contents($cfilename, '<?php if(!defined("IN_PHPSCUP"))exit("hacking");?>' . $out)) {
				return false;
			}
		} else {

			if (!($out = file_get_contents($cfilename))) {
				return false;
			}
		}
		return $out; // 返回html数据
	}

	/**
	 * 处理字符串函数
	 */
	function template_str($fileContent) {
		$fileContent = preg_replace('/^(\xef\xbb\xbf)/', '', $fileContent); //EFBBBF    

		$fileContent = preg_replace("/\\\$([0-9a-zA-Z.|:_\"',$;]*)/ies", "\$this->var_replace('\\1')", $fileContent);
		
		$fileContent = preg_replace("/\<phpscup\:links\s*\(\s*(.+?)\s*\)\s*\/\>/ies", "\$this->_phpscup_links('\\1')", $fileContent);

		$fileContent = preg_replace("/\<phpscup\:rollpic\s*\(\s*(.+?)\s*\)\s*\/\>/ies", "\$this->_phpscup_rollpic('\\1')", $fileContent);	

		$fileContent = preg_replace("/\<phpscup\:nav\s*\(\s*(.+?)\s*\)\s*\/\>/ies", "\$this->_phpscup_nav('\\1')", $fileContent);
		
		$fileContent = preg_replace("/\<phpscup\:category:alonepage\s*\(\s*(.+?)\s*\)\s*\/\>/ies", "\$this->_phpscup_category_alonepage('\\1')", $fileContent);	

		$fileContent = preg_replace("/\<phpscup\:category:new\s*\(\s*(.+?)\s*\)\s*\/\>/ies", "\$this->_phpscup_category_new('\\1')", $fileContent);	
		
		$fileContent = preg_replace("/\<phpscup\:category:prot\s*\(\s*(.+?)\s*\)\s*\/\>/ies", "\$this->_phpscup_category_prot('\\1')", $fileContent);									

		$fileContent = preg_replace("/\<phpscup\:database\s*\(\s*(.+?)\s*\)\s*\/\>/ies", "\$this->_phpscup_database('\\1')", $fileContent);

		$fileContent = preg_replace("/\<\!\-\-\s*\{\/if\}\s*\-\-\>/is", "<?php } ?>", $fileContent);

		$fileContent = preg_replace("/\<\!\-\-\s*\{\/foreach\}\s*\-\-\>/is", "<?php } ?>", $fileContent);

		$fileContent = preg_replace("/\<\!\-\-\s*\{else\}\s*\-\-\>/is", "<?php } else { ?>", $fileContent);

		$fileContent = preg_replace("/\<\!\-\-\s*\{else\s*if\s+\(\s*(.+?)\s*\)\s*\}\s*\-\-\>/ies", "\$this->__replace('<?php } else if(\\1) { ?>')", $fileContent);

		$fileContent = preg_replace("/\<\!\-\-\s*\{if\s*\(\s*(.+?)\s*\)\s*\}\s*\-\-\>/ies", "\$this->__replace('<?php if(\\1) { ?>')", $fileContent);

		$fileContent = preg_replace("/\<\!\-\-\s*\{url\s*\(\s*(.+?)\s*\)\s*\}\s*\-\-\>/ies", "\$this->_url('\\1')", $fileContent);

        $fileContent = preg_replace("/\<\!\-\-\s*\{urlhtml\s*\(\s*(.+?)\s*\)\s*\}\s*\-\-\>/ies", "\$this->_urlhtml('\\1')", $fileContent);

		$fileContent = preg_replace("/\<\!\-\-\s*\{css\s*\(\s*(.+?)\s*\)\s*\}\s*\-\-\>/ies", "\$this->_css('\\1')", $fileContent);

		$fileContent = preg_replace("/\<\!\-\-\s*\{js\s*\(\s*(.+?)\s*\)\s*\}\s*\-\-\>/ies", "\$this->_js('\\1')", $fileContent);

		$fileContent = preg_replace("/\<\!\-\-\s*\{foreach\s*\(\s*(.+?)\s*\)\s*\}\s*\-\-\>/ies", "\$this->__replace('<?php foreach((array)\\1) { ?>')", $fileContent);

		$fileContent = preg_replace("/\<\!\-\-\s*\{inc\s*\(\s*(.+?)\s*\)\s*\}\s*\-\-\>/ies", "\$this->_include(\"\\1\")", $fileContent);

		$fileContent = preg_replace("/\<\!\-\-\s*\{widget\s*\(\s*(.+?)\s*\)\s*\}\s*\-\-\>/ies", "\$this->_widget('\\1')", $fileContent);
		
		$fileContent = preg_replace("/\{([\\\$a-zA-Z0-9_\[\]\\\ \-\'\,\;\%\(\)\*\/\.\>\'\"\$\x7f-\xff]+)\}/ies", "\$this->__replace('<?php echo \\1;?>')", $fileContent);
		
		return $fileContent;
	}

	function _widget($string) {
		$string = preg_replace("/\{([\\\$a-zA-Z0-9_\[\]\\\ \-\'\,\;\%\*\/\.\(\)\>\'\"\$\x7f-\xff]+)\}/ies", "\$this->__replace('\\1')", $string);
		$string = str_replace("'", "", $string);

		unset ($array, $out, $wfilename);
		$array = explode('&', $string);
		$array[0] = trim($array[0]);
		$array[1] = trim($array[1]);

		$wfilename = ROOT_PATH . '/scup/widget/' . $array[0] . '/widget.html';
		$out = file_get_contents($wfilename);
		$out = $this->template_str($out);

		return '<?php $this->__widget(\'' . $array[0] . "','" . $array[1] . '\'); ?>' . "\n" . $out;
	}

	function __widget($app, $act) {
		if ($this->widget_base_load == null) {

			require_once (ROOT_PATH . '/scupcore/widget.base.php');
			$this->widget_base_load = '1';
		}
		require ($this->widget_dir . '/' . $app . '/widget.php');

		$class_name = ucfirst($app) . 'Widget';
		new $class_name ($act);
	}

	function _css($string) {
		$string1 = preg_replace("/\{([\\\$a-zA-Z0-9_\[\]\\\ \-\'\,\;\%\*\/\.\(\)\>\'\"\$\x7f-\xff]+)\}/ies", "\$this->__replace('\\1')", $string);
		if ($string1 == $string) {
			$string1 = str_replace("'", "", $string1);

			$string1 = '<?php echo SITE_URL;?>/<?php echo $GLOBALS[\'SCup\']->SCup_name ;?>/view/<?php echo  VIEW_TYPE ;?>/style/<?php echo CSS_TYPE ;?>/css/' . $string1;			 


			return '<link href="' . $string1 . '" rel="stylesheet" type="text/css">';
		} else {
			$string1 = str_replace("'", "", $string1);

			$string1 = '<?php echo SITE_URL;?>/<?php echo $GLOBALS[\'SCup\']->SCup_name ;?>/view/<?php echo  VIEW_TYPE ;?>/style/<?php echo CSS_TYPE ;?>/css/' . $string1;			 

			return '<link href="' . $string1 . '" rel="stylesheet" type="text/css">';
		}
	}

	function _js($string) {
		$string1 = preg_replace("/\{([\\\$a-zA-Z0-9_\[\]\\\ \-\'\,\;\%\*\/\.\(\)\>\'\"\$\x7f-\xff]+)\}/ies", "\$this->__replace('\\1')", $string);
		if ($string1 == $string) {
			$string1 = str_replace("'", "", $string1);

			$string1 = '<?php echo SITE_URL;?>/<?php echo $GLOBALS[\'SCup\']->SCup_name ;?>/view/<?php echo  VIEW_TYPE ;?>/style/<?php echo CSS_TYPE ;?>/js/' . $string1;			 
		 			
			return '<script type="text/javascript" src="' . $string1 . '"></script>';
		} else {
			$string1 = str_replace("'", "", $string1);

			$string1 = '<?php echo SITE_URL;?>/<?php echo $GLOBALS[\'SCup\']->SCup_name ;?>/view/<?php echo  VIEW_TYPE ;?>/style/<?php echo CSS_TYPE ;?>/js/' . $string1;			 

			return '<script type="text/javascript" src="' . $string1 . '"></script>';
		}
	}

	function _phpscup_links($string) 
	{

		$str = str_replace(array('"',"'"),array("",""), $string);	
		return  '<?php get_view()->assign("'.$str.'",@include(ROOT_PATH . "/data/cache/links_".trim($GLOBALS["Lang"]->_lang_tp).".php")'.'); ?>';
	}
	function _phpscup_rollpic($string) 
	{

		$str = str_replace(array('"',"'"),array("",""), $string);	
		return  '<?php get_view()->assign("'.$str.'",@include(ROOT_PATH . "/data/cache/rollpic_".trim($GLOBALS["Lang"]->_lang_tp).".php")'.'); ?>';
	}
	function _phpscup_nav($string) 
	{

		$str = str_replace(array('"',"'"),array("",""), $string);	
		return  '<?php get_view()->assign("'.$str.'",@include(ROOT_PATH . "/data/nav/scup.".trim($GLOBALS["Lang"]->_lang_tp).".nav.php")'.'); ?>';
	}

	function _phpscup_category_alonepage($string) 
	{

		$str = str_replace(array('"',"'"),array("",""), $string);	
		return  '<?php get_view()->assign("'.$str.'",@include(ROOT_PATH . "/data/category/category_alonepage_".trim($GLOBALS["Lang"]->_lang_tp).".php")'.'); ?>';
	}		
	function _phpscup_category_new($string) 
	{

		$str = str_replace(array('"',"'"),array("",""), $string);	
		return  '<?php get_view()->assign("'.$str.'",@include(ROOT_PATH . "/data/category/category_new_".trim($GLOBALS["Lang"]->_lang_tp).".php")'.'); ?>';
	}	

	function _phpscup_category_prot($string) 
	{

		$str = str_replace(array('"',"'"),array("",""), $string);	
		return  '<?php get_view()->assign("'.$str.'",@include(ROOT_PATH . "/data/category/category_prot_".trim($GLOBALS["Lang"]->_lang_tp).".php")'.'); ?>';
	}	
/*
属性 iconname , tablename 数据库表名, fields 先生字段 ,conditions 条件, order , limit, return, url

*/
	function _phpscup_database($string) 
	{
		$string = preg_replace("/\{([\\\$a-zA-Z0-9_\[\]\\\ \-\'\,\;\%\*\/\.\(\)\>\'\"\$\x7f-\xff]+)\}/ies", "\$this->__replace('\\1')", $string);
		$string = str_replace(array('"',"'"),array("",""), $string);	
		$array = explode('|', $string);
		$temp_array = array();
        foreach($array as $key=>$value)
		{ 
		  if(!empty($value))
		  {
		    $array1 = explode(':', $value);
			if(isset($array1[0]))
			{
		    $array1[0] = trim($array1[0]);			
			}
			else
			{
		    $array1[0] = '';			
			}
			if(isset($array1[1]))
			{
		    $array1[1] = trim($array1[1]);			
			}
			else
			{
		    $array1[1] = '';			
			}
			if($array1[0])
			{
			  $temp_array[$array1[0]] = $array1[1];			
			}	

		  }
	 
		}
        if(!isset($temp_array['iconname']))
		{
		$temp_array['iconname'] = 'temp_iconname_db';
		}
        if(!isset($temp_array['tablename']))
		{
		return '';
		}	
        if(!isset($temp_array['fields']))
		{
		$temp_array['fields'] = '*';
		}			
        if(!isset($temp_array['conditions']))
		{
		$temp_array['conditions'] = '';
		}	
        if(!isset($temp_array['order']))
		{
		$temp_array['order'] = '';
		}		
        if(!isset($temp_array['limit']))
		{
		$temp_array['limit'] = '';
		}	
        if(!isset($temp_array['return']))
		{
		$temp_array['return'] = 'all';
		}			
        if(!isset($temp_array['url']))
		{
		$temp_array['url'] = '';
		}							 
	    $sql_str =  'get_view()->assign("'.$temp_array['iconname'].'",get_model()->Page_And_S_Sql_Exe(array("table" => "'.$temp_array['tablename'].'","fields" => "'.$temp_array['fields'].'","conditions" => "'.$temp_array['conditions'].'","order" => "'.$temp_array['order'].'","limit" => "'.$temp_array['limit'].'","return" => "'.$temp_array['return'].'","url" =>"'.$temp_array['url'].'")));';		
		
		return  '<?php '.$sql_str.' ?>';
	}	
	
	function _url($string) {
		$string1 = preg_replace("/\{([\\\$a-zA-Z0-9_\[\]\\\ \-\'\,\;\%\*\/\.\(\)\>\'\"\$\x7f-\xff]+)\}/ies", "\$this->__replace('\\1')", $string);
		if ($string1 == $string) {
			$string1 = str_replace("'", "", $string1);
		    $string1 = preg_replace("/\\\$([\\\$a-zA-Z0-9_\[\]\\\ \-\'\,\;\%\(\)\*\/\.\>\'\"\$\x7f-\xff]+)/ies", "\$this->var_add_str('\\1')", $string1);
			return '<?php echo $this->_write_url("' . $string1 . '"); ?>';
		} else {
			$string1 = str_replace("'", "", $string1);
		    $string1 = preg_replace("/\\\$([\\\$a-zA-Z0-9_\[\]\\\ \-\'\,\;\%\(\)\*\/\.\>\'\"\$\x7f-\xff]+)/ies", "\$this->var_add_str('\\1')", $string1);
			return '<?php echo $this->_write_url("' . $string1 . '"); ?>';
		}
	}

    function _urlhtml($string)
	{	   
		$string1 = preg_replace("/\{([\\\$a-zA-Z0-9_\[\]\\\ \-\'\,\&\;\%\*\/\.\(\)\>\'\"\$\x7f-\xff]+)\}/ies",  "\$this->__replace('\\1')", $string);		
		if($string1==$string)
		{
		 $string1 =  str_replace("'", "",$string1);	
		 $string1 = preg_replace("/\\\$([\\\$a-zA-Z0-9_\[\]\\\ \-\'\,\;\%\(\)\*\/\.\>\'\"\$\x7f-\xff]+)/ies", "\$this->var_add_str('\\1')", $string1);		 
         return '<?php echo $this->_write_url_html("'.$string1.'"); ?>';			
		}
		else
		{	
			
		 $string1 =  str_replace("'", "",$string1);		
		 $string1 = preg_replace("/\\\$([\\\$a-zA-Z0-9_\[\]\\\ \-\'\,\;\%\(\)\*\/\.\>\'\"\$\x7f-\xff]+)/ies", "\$this->var_add_str('\\1')", $string1);
         return '<?php echo $this->_write_url_html("'.$string1.'"); ?>';			
		
		}	
				
    }
  
	function var_add_str($str='') 
	{

		if(empty($str))return '';
		 $str = str_replace(array('[',']'),array("['","']"), $str);
		return '".$'.$str.'."';
	}

	function _include($filename) {
		$vfilename = $this->template_dir . '/' . $filename;
		$out = file_get_contents($vfilename);
		$out = $this->template_str($out);
		return $out;
	}

	function __replace($string) {

		return str_replace('\"', '"', $string);
	}

	function picdir($string) {
		$root_dir = (UPFILE_PATH == '') ? (SITE_URL . '/upfiles') : (SITE_URL . '/' . UPFILE_PATH);
		return $root_dir . '/' . $string;
	}

	function owndate($value) {
		return date("Y-m-d G:i:s", $value);
	}

	function var_replace($string) {
		$s = explode('|', $string);

		$string = explode('.', $s[0]);

		if (preg_match('/^(_key|_value|_GET|_POST|_REQUEST|GLOBALS)?[0-9]*$/i', $string[0]))
		{
			$k = '$' . $string[0];
		} else 
		{
		
			   if(strstr($string[0], '$')||strstr($string[0], '#'))
			   {
              $k = '$this->_var[' . $string[0] . ']';
			   }
			   else
			   {
              $k = '$this->_var[\'' . $string[0] . '\']';
			   }		
		
			
		}

		for ($i = 1; $i < count($string); $i++) {
			if (!empty ($string[$i])||$string[$i]=='0') 
			{
			   if(strstr($string[$i], '$')||strstr($string[$i], '#'))
			   {
			   $k .= '[' . $string[$i] . ']';
			   }
			   else
			   {
			   $k .= '[\'' . $string[$i] . '\']';
			   }
			}
		}
        if(!isset($s[1]))
		{
		$s[1] ='';
		}
		$sk = explode(':', $s[1]);
		$s[1] = trim($sk[0]);

		switch ($s[1]) {
			case 'escape' :
				$s[1] = trim($sk[1], '"');
				if ($s[1] == 'html') {
					$k = 'htmlspecialchars(' . $k . ')';
				}
				else if ($s[1] == 'url') {
					$k = 'urlencode(' . $k . ')';
				}
				else if ($s[1] == 'quotes') {
					$k = 'addslashes(' . $k . ')';
				}
				else if ($s[1] == 'input') {
					$k = 'str_replace(\'"\',\'&quot;\',' . $k . ')'; //str_replace当中不能用空格
				}
				else if ($s[1] == 'editor') {
					$k = 'html_filter(' . $k . ')';
				} else {
					$k = 'htmlspecialchars(' . $k . ')';
				}

				break;

			case 'nl2br' :
				$k = 'nl2br(' . $k . ')';
				break;

			case 'dateymd' :
				$k = 'date("Y-m-d",' . $k . ')';
				break;

			case 'dateymdgis' :
				$k = '$this->owndate(' . $k . ')';
				break;
			case 'picdir' :
				$k = '$this->picdir(' . $k . ')';
				break;
			case 'cutstr' :
				$k = 'psp_cutstr(' . $k . ','.$sk[1].')';
				break;
			default :

				break;
		}

		return $k;
	}
}
?>